package com.macrounion.atv.service.service.impl;

import java.util.HashMap;
import java.util.List;

import com.macrounion.atv.service.entity.ProtocolC;
import com.macrounion.atv.service.service.ProtocolCService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.macrounion.atv.service.entity.Channel;
import com.macrounion.atv.service.mapper.ChannelMapper;
import com.macrounion.atv.service.mapper.ChannelMapperExt;
import com.macrounion.atv.service.service.ChannelService;
import com.macrounion.base.service.service.impl.BaseServiceImpl;

@Service
public class ChannelServiceImpl extends BaseServiceImpl<ChannelMapper, Channel> implements ChannelService {

    @Autowired
    private ChannelMapperExt channelMapperExt;

    @Override
    public int findCount(String deviceId, String channelCode) {
        return channelMapperExt.findCount(deviceId,channelCode);
    }

    @Override
    public int updateTranslate(Channel channel) {
        return channelMapperExt.updateTranslate(channel);
    }

    @Override
    public int updateChannelCode(Channel channel) {
        return channelMapperExt.updateChannelCode(channel);
    }

	@Override
	public Channel getByDeviceIdandChannelCode(String deviceId, String channelCode) {
		return channelMapperExt.getByDeviceIdandChannelCode(deviceId,channelCode);
	}

	@Override
	public String getFxKey(String deviceCode,String channelCode) {
		return ("C("+deviceCode+"_"+channelCode+")").toUpperCase();
	}
    @Override
    public int batchUpdate(HashMap<String, Object> mapChannel) {
        return channelMapperExt.batchUpdate(mapChannel);
    }

    @Override
    public int clearChannelByDeviceId(String deviceId) {
        return channelMapperExt.clearChannelByDeviceId(deviceId);
    }

    @Override
    public int initProtocolChannel(String deviceId) {
        return channelMapperExt.initProtocolChannel(deviceId);
    }

    @Override
    public int reductionChannelName(String deviceId) {
        return channelMapperExt.reductionChannelName(deviceId);
    }


    @Override
    public List<Channel> getChannelListByDevice(String deviceId, String searchStr,Boolean isVirtual) {
        return channelMapperExt.getChannelListByDevice(deviceId,searchStr,isVirtual);
    }

    @Override
    public String getChannelCode(String code) {
		if(code.startsWith("0"))
			return getChannelCode(code.substring(1));
		return code;
	}

    @Override
    public List<Channel> getChannelListByIds(List<String> ids) {
        return channelMapperExt.getChannelListByIds(ids);
    }

    @Override
    public Channel getVirtualChannel(String virtualId) {
        return channelMapperExt.getVirtualChannel(virtualId);
    }

    @Override
    public boolean removeByVirtualId(String virtualId) {
        channelMapperExt.removeByVirtualId(virtualId);
        return true;
    }

    @Override
    public List<ProtocolC> getRepeatChannelList(String deviceId) {
        return channelMapperExt.getRepeatChannelList(deviceId);
    }

	@Override
	public List<Channel> getAll() {
		return channelMapperExt.getAll();
	}
}